<!DOCTYPE >
<html lang="zh-cn">

	<head>
		<title>后台管理-入会申请管理</title>
		<% include ../partials/head %>
			<link rel="stylesheet" href="/assets/js/button/ladda/ladda.min.css">
			<script type="text/javascript">
				var aUthentic = {
					operator: function() {
						$("table").on('click', '.ok', function() {
							$this = $(this)
							if ($this.prev().prev().val() == -1||$this.prev().val()=="") {
								alert("请选择会员类型和填写会员印象");
							} else {
								if (window.confirm('你确定要认证该用户吗？')) {
									//认证 0通过，1拒绝
									$.post("/admin/member/apply/handle", {
										"member_type": $this.prev().prev().val(),
										"impress":$this.prev().val(),
										"authenticationId": $this.attr('authId'),
										"isAuthentic": 0
									}, function(json) {
										if (json.code == 0) {
											$this.parents('tr').remove();
										} else {
											alert(json.msg);
										}
									}, 'json');
								} else {
									//取消
								}
							}
						}).on('click', '.pass', function() {
							$this = $(this);
							if ($this.prev().val() == "") {
								alert("请输入拒绝原因");
							} else {
								if (window.confirm('你确定要拒绝该用户的认证吗？')) {
									//拒绝
									$.post("/admin/member/apply/handle", {
										"authenticationId": $this.attr('authId'),
										"isAuthentic": 1,
										"content": $this.prev().val()
									}, function(json) {
										if (json.code == 0) {
											$this.parents('tr').remove();
										} else {
											alert(json.msg);
										}
									}, 'json');
								} else {
									//取消
								}
							}
						}).on("click", ".contact", function() {
							$this = $(this)
							if (window.confirm('你确定要联系他么？')) {
								//拒绝 
								$.post("/admin/member/contact", {
									"userId": $this.attr('userId'),
									"content": $this.parent().find(".contactContent").val()
								}, function(json) {
									if (json.code == 0) {
										alert(json.msg);
									} else {
										alert(json.msg);
									}
								}, 'json');
							} else {
								//取消
							}
						})
					},
					init: function() {
						this.operator();
					}
				}
				$(document).ready(function() {
					aUthentic.init();
				})
			</script>
	</head>

	<body>
		<header>
			<!-- Preloader -->
			<div id="preloader">
				<div id="status">&nbsp;</div>
			</div>
		</header>
		<div class="ch-container">

			<!-- 首页内容 -->
			<div class="wrap-fluid">
				<div class="container-fluid paper-wrap bevel tlbr">

					<!-- CONTENT -->
					<!--TITLE -->

					<!--/ TITLE -->

					<!-- BREADCRUMB -->
					<ul id="breadcrumb">
						<li>
							<span class="entypo-home"></span>
						</li>
						<li><i class="fa fa-lg fa-angle-right"></i>
						</li>
						<li><a href="#" title="公司管理">会员入会管理</a>
						</li>
					</ul>

					<!--测试数据-->
					<div class="content-wrap">
						<div class="row">
							<div class="col-sm-12">
								<div class="nest" id="FootableClose">
									<div class="title-alt">
										<h6>申请管理</h6>
										<div class="titleClose">
											<a class="gone" href="#FootableClose">
												<span class="entypo-cancel"></span>
											</a>
										</div>
										<div class="titleToggle">
											<a class="nav-toggle-alt" href="#Footable">
												<span class="entypo-up-open"></span>
											</a>
										</div>

									</div>
									<div class="body-nest" id="Filtering">

										<div class="row" style="margin-bottom:10px;">
											<div class="col-sm-4">
												<input class="form-control" id="filter" placeholder="Search..." type="text">
											</div>
											<div class="col-sm-2">
												<select class="filter-status form-control">
													<option>全部</option>
													<option value="未处理">未处理</option>
													<option value="已通过">已通过</option>
													<option value="已拒绝">已拒绝</option>
												</select>
											</div>
											<!--<div class="col-sm-2">
													<select class="filter-num form-control">
														<option value="1">每页10个
															<option value="2">每页50个
																<option value="3">每页100个
													</select>
												</div>-->
											<div class="col-sm-6">

												<a href="#clear" style="margin-left:10px;" class="pull-right btn btn-info clear-filter" title="clear filter">重置</a>
											</div>

										</div>
										<table class="table-striped footable-res footable metro-blue data-table" data-page-size="30" data-filter="#filter" data-filter-text-only="true">
											<thead>
												<tr>
													<th data-toggle="true"></th>
													<th>昵称</th>
													<th>团号</th>
													<th>微信号</th>
													<th>需验证图片</th>
													<th>处理状态</th>
													<th data-hide="all" data-sort-initial="ascending">申请时间</th>
												</tr>
											</thead>
											<tbody>
												<% if (typeof authentications != "undefined") { %>
													<% authentications.forEach(function(authentication,index) { %>

														<tr>
															<td class="center">
																<%=index%>
															</td>
															<td class="center">
																<a href="/admin/userinfo?userId=<%=authentication.get('sponsor').id%>">
																	<%= authentication.get("sponsor").get("nickname") %>
																</a>
															</td>
															<td class="center">
																<%= authentication.get("sponsor").get("molianId") %>
															</td>
															<td class="center">
																<%= authentication.get("sponsor").get("weChat") %>
															</td>
															<td class="center">
																<% if (typeof authentication.get('avatar') != "undefined") { %>
																	<a href="<%=authentication.get('avatar').url()%>" target="_blank"> <img style="max-height:100px" src="<%=authentication.get('avatar').url()%>"></a>
																	<% } %>
															</td>

															<td class="center">
																<% if(authentication.get("status")==1){ %>
																	<span class="btn">已处理</span>
																	<% } %>
																		<% if(authentication.get("status")==2){ %>
																			<span class="btn public ladda-button">已拒绝</span>
																			<% } %>
																				<% if(authentication.get("status")==0){ %>
																					<p>
																						<select class="member_type">
																							<option value="-1">选择会员类型</option>
																							<option value="2">白金会员</option>
																							<option value="1">黄金会员</option>
																							<option value="0">普通会员</option>
																						</select>
																						<input class="effect" type="text" placeholder="会员印象" style="color:#000">
																						<span class="btn public ladda-button btn-success ok " authId=<%=authentication.id%>>通过</span></p>
																					<p>
																						<input class="contactContent" type="text" placeholder="拒绝原因" style="color:#000">
																						<span class="btn public ladda-button btn-danger pass" authId=<%=authentication.id%>>拒绝</span></p>
																					<% } %>
															</td>

															<td class="center">
																<%= Format(authentication.createdAt) %>
															</td>

														</tr>
														<% }) %>
															<% } %>

											</tbody>
											<tfoot>
												<tr>
													<td colspan="5">
														<div class="pagination pagination-centered"></div>
													</td>
												</tr>
											</tfoot>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
					<!-- END OF BREADCRUMB -->

					<!-- /END OF CONTENT -->

					<!-- FOOTER -->
					<div class="footer-space"></div>
					<div id="footer">
						<div class="devider-footer-left"></div>
						<div class="time">
							<p id="spanDate">
								<p id="clock">
						</div>
						<div class="copyright">Made by HT
							<span class="entypo-heart"></span>广州聚脉互联网络服务有限公司</div>
						<div class="devider-footer"></div>

					</div>
					<!-- / END OF FOOTER -->

				</div>
			</div>

		</div>
		<% include ../partials/external %>
			<script src="/assets/js/button/ladda/spin.min.js"></script>

			<script src="/assets/js/button/ladda/ladda.min.js"></script>

			<script src="/assets/js/footable/js/footable.filter.js"></script>

			<script type="text/javascript">
				$(function() {
					$('table').on("click", ".viewaddr", function() {
						window.location.href = $(this).attr("addr");
					}).on("click", ".editarticle", function() {
						window.location.href = "/admin/home/article/edit?id=" + $(this).attr("articleId");
					})
				});
			</script>
			<script type="text/javascript">
			</script>
	</body>

</html>